package elitech.vietnam.weatherfashion.tabs.settings;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import elitech.vietnam.weatherfashion.MainActivity;
import elitech.vietnam.weatherfashion.R;

public class PicPickerEditProfileDialog extends Dialog implements
		View.OnClickListener {

	private Fragment fragment;

	public PicPickerEditProfileDialog(Context context, Fragment fragment) {
		super(context);
		this.fragment = fragment;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.layout_dialogcamera);
		((Button) findViewById(R.id.dialogcamera_button_camera))
				.setOnClickListener(this);
		((Button) findViewById(R.id.dialogcamera_button_gallery))
				.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		Intent intent = null;
		int req = 0;
		switch (v.getId()) {
		case R.id.dialogcamera_button_camera:

			intent = new Intent(
					android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
			req = MainActivity.REQ_CODE_EDIT_PROFILE_CAMERA;
			break;

		case R.id.dialogcamera_button_gallery:

			intent = new Intent(Intent.ACTION_PICK,
					MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
			req = MainActivity.REQ_CODE_EDIT_PROFILE_ALBUM;
			break;

		default:
			break;
		}
		if (intent != null)
			fragment.startActivityForResult(intent, req);
		dismiss();
	}
}
